package com.qfedu.utils;

import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.TimeZone;

public class StringUtils {

    public static String getTime(int second){

        //对 数据进行格式化的工具
        DecimalFormat decimalFormat = new DecimalFormat("00");
        int hour = second/3600;
        int minute= second%3600/60;
        int second2 = second%3600%60;

        String _hour=decimalFormat.format(hour);
        String _minute = decimalFormat.format(minute);
        String _second = decimalFormat.format(second2);
        // StringBuffer/StringBuilder 拼接字符串   和  str1+str2 效率高
        return _hour+":"+_minute+":"+_second;
    }


    public static String getNiceTime(long time){

        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH:mm:ss");
        int zone  =TimeZone.getDefault().getRawOffset();
        System.out.println(zone);//28800000 8小时
        return simpleDateFormat.format(time- TimeZone.getDefault().getRawOffset());

    }

    public static void main(String[] args) {
        System.out.println(getTime(36886));
        System.out.println(getNiceTime(36886000));
    }
}
